package com.example.mainstream;

import android.app.Application;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;

import com.example.shopapp.bean.Merchant;
import com.example.shopapp.bean.User;
import com.example.shopapp.dao.DaoMaster;
import com.example.shopapp.dao.DaoSession;
import com.example.shopapp.database.GreenDaoManager;
import com.kongzue.dialogx.DialogX;
import org.xutils.x;
import org.xutils.DbManager;

public class App extends Application {

    private static App singstance;
    public User user =null;
    public Merchant merchant =null;
    private static Context context;


    public static DbManager dbManager;//数据库存储


//



    static DbManager.DaoConfig daoConfig = new DbManager.DaoConfig()
            .setDbVersion(1)
            .setDbUpgradeListener(new DbManager.DbUpgradeListener() {
                @Override
                public void onUpgrade(DbManager db, int oldVersion, int newVersion) {

                }
            });
    /**
     * 获取全局上下文
     */
    public static Context getContext() {
        return context;
    }

    public static App getInstance(){
        return singstance;
    }
    @Override
    public void onCreate() {
        super.onCreate();
            singstance = this;
            context = this.getApplicationContext();
            x.Ext.init(this);
            if (dbManager == null) {
                dbManager = x.getDb(daoConfig);
            }
        //全局配置GreenDao
        GreenDaoManager.getmInstance();
        //初始化
        DialogX.init(this);
    }
}
